FROM alpine:3.12

ARG VERSION

ENV NFS_DIR="/nfs-share" \
    NFS_DOMAIN="*" \
    NFS_OPTION="fsid=0,rw,sync,insecure,all_squash,anonuid=65534,anongid=65534,no_subtree_check,nohide"

RUN sed -i 's/dl-cdn.alpinelinux.org/opentuna.cn/g' /etc/apk/repositories \
 && apk add --no-cache nfs-utils bash \
 && mkdir -p /var/lib/nfs/v4recovery \
 && mkdir -p /var/lib/nfs/rpc_pipefs /var/lib/nfs/v4recovery \
 && echo "rpc_pipefs	/var/lib/nfs/rpc_pipefs	rpc_pipefs	defaults	0 0" >> /etc/fstab \
 && echo "nfsd	/proc/fs/nfsd	nfsd	defaults	0 0" >> /etc/fstab


COPY nfsd.sh /bin/nfsd.sh

EXPOSE 2049/tcp

CMD ["/bin/nfsd.sh"]
